<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>修改密码</title>
    <link href="css/bootstrap-cerulean.css" rel="stylesheet">
    <link href="css/charisma-app.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }
    </style>
    <script src="js/common/public.js"></script>
    <script src="js/base64.js"></script>
    <script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#update").click(function(){
                var urlMsg  = parseUrl(window.location.search);

                var password = $("#password").val();
                var newPassword = $("#newPassword").val();
                var studentNumber = urlMsg.studentNumber;
                if (newPassword ==null || newPassword.length<8){
                    $("#errorInfo").html('<span style="color: red">密码长度不得小于8位！<span>');
                    return false;
                }
                var reg = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/);
                if (!reg.test(newPassword)){
                    $("#errorInfo").html('<span style="color: red">密码必须包含数字和字母！<span>');
                    return false;
                }
                if (newPassword!=password){
                    $("#errorInfo").html('<span style="color: red">两次密码输入不一致！<span>');
                    return false;
                }
                $("#errorInfo").html('');
                //Ajax调用处理
                var html = $.ajax({
                    type: "PUT",
                    url: "http://localhost:1066/student/updatePassword?token="+urlMsg.token,
                    data: {studentNumber: studentNumber, password: newPassword,id:urlMsg.id},
                    async: false
                }).responseText;
                var result=eval('('+html+')');
                if (result.code==200){
                    alert("修改成功！下次登录生效");
                    window.history.back(-1);
                }
            });
        });
    </script>
</head>

<body>

<div class="navbar">
    <div class="navbar-inner" style="padding-top:0px; padding-bottom:0px">
        <div class="container-fluid">
            <a class="btn btn-navbar">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
            <a class="brand" href="student.action"> <img src="images/logo20.png"/> <span>软件学院操行管理系统</span></a>
        </div>
    </div>
</div>

<div class="container-fluid"
     style="padding-left:25%; padding-right:25%; padding-top:50px">
    <div class="row-fluid">
        <div id="content" class="span10" style="width:100%;">
            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header well">
                        <h2>
                            <i class="icon-edit"></i>修改密码
                        </h2>
                    </div>
                    <div class="box-content" style="text-align:center; padding-top:50px">
                        <form action="" method="post">
                            <fieldset>
                                <h1>修改学生密码</h1>
                                <br><br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:14px">新的密码：</span><input name="password" class="input"
                                                                                        id="newPassword" type="password"
                                                                                        style="height:30px;">
                                    </div>
                                </div>
                                <br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:14px">密码确认：</span><input name="password" class="input"
                                                                                        id="password" type="password"
                                                                                        style="height:30px;">
                                    </div>
                                </div>
                                <div class="displayinfo" id="errorInfo">
                                <span>
                                </span>
                                </div>
                                <br>
                                <br>

                                <div class="form-actions">
                                    <button type="button" id="update" class="btn btn-primary" style="width:100px;" >提交</button>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <button class="btn" onclick="javascript:history.go(-1);" type="reset"
                                            style="width:100px;">取消
                                    </button>
                                </div>
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>